package MainApplication;

import java.awt.event.ComponentListener;
import java.awt.event.FocusListener;

import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableModel;

/**
 * this class implements listener for choosing selected row from table
 * @author Daniel
 *
 */
class SelectionListener implements ListSelectionListener {
  JTable table;
public int selRows = -1;

  /** 
   * set selection listener on the supplied table
 * @param table
 */
SelectionListener(JTable table) {
    this.table = table;
  }

  
  /**
 * @return selRow - the currently selected row on the table
 */
public int getSelRows()
{
	return selRows;
}


public void valueChanged(ListSelectionEvent e) {
	   int maxRows;
	   Object value;

	   if (!e.getValueIsAdjusting()) {        
	     selRows = table.getSelectedRow();
	     System.out.println(selRows);
	     }
	    }
}